load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("//bazel:prost.bzl", "generated_files_check")

package(default_visibility = ["//visibility:public"])

DEPENDENCIES = [
    # Keep sorted.
    "@crate_index//:prost",
]

DEV_DEPENDENCIES = [
    # Keep sorted.
    "//rs/registry/proto/generator:lib",
    "//rs/test_utilities/compare_dirs",
    "@crate_index//:tempfile",
]

rust_library(
    name = "proto",
    srcs = glob([
        "src/**",
    ]),
    crate_name = "ic_registry_common_proto",
    version = "0.9.0",
    deps = DEPENDENCIES,
)

filegroup(
    name = "protos",
    srcs = glob(["proto/**/*.proto"]),
)

generated_files_check(
    name = "check_generated_files",
    srcs = ["tests/check_generated_files.rs"],
    data = [
        ":protos",
    ] + glob([
        "src/gen/**",
    ]),
    manifest_dir = "rs/registry/proto",
    deps = DEV_DEPENDENCIES,
)

rust_test(
    name = "proto_test",
    crate = ":proto",
    deps = DEV_DEPENDENCIES,
)
